package com.art.sunflower.mapper;

import com.art.sunflower.pojo.Work;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface WorkMapper {
    @Insert("insert into work(teacher_id,classes_id,stu_id,work_name, url,type,date,rank) values(#{teacherId},#{classesId}," +
            "#{stuId},#{workName},#{url},#{type},#{date},false)")
    int insertWork(Work work);

    @Update("update work set teacher_id=#{teacherId},classes_id=#{classesId},stu_id=#{stuId},work_name=#{workName}" +
            "url=#{url},type=#{type},date=#{date}" + "where id = #{id}")
    int updateWork(Work work);

    @Update("update work set rank=#{rank} where id = #{id}")
    int updateRank(int id, boolean rank);

    @Delete("delete from work where id = #{id} and teacher_id=#{teacherId}")
    int deleteWork(int id);

    @Select("select * from work_information_view where id=#{id} and teacher_id=#{teacherId}")
    Work selectOneWork(int id, int teacherId);

    @Select("select * from work_information_view where teacher_id=#{teacherId}")
    List<Map<String, Object>> listAllWork(int teacherId);

    @Select("select id from teacher where user_id=#{id}")
    int selectTea(int id);

    @Select("select classesId, realName, classesName from students_classes_ids_view where userId = #{userId}")
    List<Map<String, Object>> selectStudentsClassesIds(Integer userId);

    @Select("select * from classes_work_view where classesId = #{classesId}")
    List<Map<String, Object>> selectClassesWork(Integer classesId);

}
